I'm a doctor, not a mechanic

Compiler directives

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

Compiler directives are lines in UnrealScript source files that affect compiler behavior and have no meaning at runtime. They are not really used anymore in Unreal Engine 3, which comes with a powerful preprocessor instead.

Directives are parsed during the compile process, not before that. This means they cannot be used in defaultproperties or cpptext sections. In fact, any directives in cpptext blocks will end up in exported header files for preprocessing by the C++ compiler.

Syntax[edit]

Compiler directives must be placed on a separate line. The syntax is as follows:

#directivename parameters

There must not be anything else before the # on that line and there shouldn't be anything after the directive name and parameters, except maybe a line comment. Directive names are case-insensitive, like any other part of UnrealScript syntax.

Unreal Engine 1/2[edit]

call[edit]

Similar to the "exec" console command in the editor and the game. Loads a list of console commands from a text file and executes them.

See exec commands for a useful selection of commands.

error[edit]

Immediately stops compiling with the message: "#Error directive encountered"

Note that there is no built-in conditional compiling, so using this directive may be quite pointless without an external preprocessor tool like UCPP.

exec[edit]

The most-used directive and probably the only one most UnrealScript programmers ever need to use. The #exec directive executes an editor console command in the context of the compiler.

See exec commands for a useful selection of commands.

Unreal Engine 2[edit]

include[edit]

Loads a text file and replaces the #include line with its content.

There are several things to watch out for when using this directive:

  • Line numbers reported in errors and warnings after the #include line will reflect the source text with the included content, so they no longer match the original source line numbers.
  • If the included file contains a defaultproperties block, it is not included directly. Instead, its content is inserted into the class's defaultproperties block.

Unreal Engine 3[edit]

The only known directive in Unreal Engine 3 is #linenumber, which is inserted by the preprocessor after an `include macro to make sure the compiler reports the line numbers the user expects.